package com.pandora.loan.home.web;

import com.pandora.loan.common.parameter.annotation.RequestData;
import com.pandora.loan.home.dto.request.*;
import com.pandora.loan.home.dto.response.*;
import com.pandora.loan.home.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

/**
 * @author developer
 */
@RestController
public class UserController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private AccountService accountService;

    /**
     * 访问令牌
     */
    @RequestMapping(value = "access_token", method = RequestMethod.POST, consumes = {MediaType.APPLICATION_JSON_UTF8_VALUE})
    public AccessTokenResponse requestAccessToken(@RequestBody AccessTokenRequest req) {
        return accountService.requestAccessToken(req);
    }
    @RequestMapping(value = "access_token", method = RequestMethod.POST, consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
    public AccessTokenResponse requestAccessTokenForm(@RequestData AccessTokenRequest req) {
        return accountService.requestAccessToken(req);
    }

}
